<%@ page import="java.util.ArrayList" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ page import="userInteraction.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="login" class="userInteraction.loginService"></jsp:useBean>
<jsp:setProperty property="*" name="login"/>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%	
	loginService logUser = new loginService();
	updateUserInformation isAdmin = new updateUserInformation();
	if(logUser.checkLogin(request.getParameter("user"), request.getParameter("pass"))==false)
	{
		session.setAttribute( "loggedIn", null );
		session.setAttribute("postback", "true");
		response.sendRedirect("../User/index.jsp");
	}
	else if(logUser.checkLogin(request.getParameter("user"), request.getParameter("pass")) == true && isAdmin.checkAdmin(request.getParameter("user")) == true) // if the login is ok and the user is an admin then he ie redirected to the administration page
	{
		session.setAttribute( "loggedIn", request.getParameter("user") );
		response.sendRedirect("../General Info/dashboard.jsp");
		session.setAttribute("whoIs",logUser.whoIsLogged(request.getParameter("user")));
	}
	else
	{
		session.setAttribute( "loggedIn", request.getParameter("user") );
		response.sendRedirect("../General Info/dashboard.jsp");
		session.setAttribute("whoIs",logUser.whoIsLogged(request.getParameter("user")));
	}
%>
</body>
</html>